//standalone version
function getDocWidth() {
    return getDocLength('w');
}
function getDocHeight() {
    return getDocLength('h');
}
function getDocLength(type,debug){
    if (type=='w') {
        type='Width'
    } else if (type=='h') {
        type='Height'
    } else {
        alert('wrong parameter'+type) 
        return;
    }
    var attrs=['offset'+type,'scroll'+type,'client'+type,'inner'+type];
    var db=document.body;
    var de=document.documentElement;
    var r=0;
    var tmp_r=0;
    var a='';
    for(var i=0;i<attrs.length;i++) {
        a=attrs[i];
        tmp_r=db[a]>de[a]?db[a]:de[a];
        if (typeof tmp_r=='undefined' || tmp_r<r) {
            continue;
        }
        c_attr=a;
        r=tmp_r;
    }
    return r;
}

//jQuery version
$(document).width();
$(document).height();
